package com.wbl.gulimall.product;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wbl.gulimall.product.entity.BrandEntity;
import com.wbl.gulimall.product.service.BrandService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

/**
 * Author: 王博纶
 * Date: 2024/6/4 9:19
 * FileName: BrondTestApplication
 * Description: 商品测试类
 */
@SpringBootTest
public class BrandTestApplication {

    @Autowired
    private BrandService brandService;

    @Test
    public void insertBrand(){
        BrandEntity brandEntity = new BrandEntity().setName("华为");
        boolean save = brandService.save(brandEntity);
        System.out.println("保存后的结果：" + save);
    }

    @Test
    public void updateBrand(){
        BrandEntity brandEntity = new BrandEntity()
                .setBrandId(1797899067565563906L)
                .setDescript("华为");
        boolean update = brandService.updateById(brandEntity);
        System.out.println("修改后的结果：" + update);
    }

    @Test
    public void queryBrand(){
        LambdaQueryWrapper<BrandEntity> queryWrapper = new LambdaQueryWrapper<BrandEntity>()
                .eq(BrandEntity::getBrandId,1797899067565563906L);
        List<BrandEntity> list = brandService.list(queryWrapper);
        list.forEach(System.out::println);
    }
}
